package com.dream.keigezhushou.Activity.kege.view;

import android.content.Context;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.dream.keigezhushou.Activity.kege.Bean.GiftBean;
import com.dream.keigezhushou.Activity.view.CircleImageView;
import com.dream.keigezhushou.R;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * Created by Administrator on 2017/3/18.
 */
public class GiftRankingView extends LinearLayout implements View.OnClickListener {
    private Context mContext;
    private OnClickListener onClickListener;
    private GiftBean mGiftBean;
    @BindView(R.id.gift_ranking_icon)
    CircleImageView giftRankingIv;

    public GiftRankingView(Context context, GiftBean mGiftBean) {
        super(context);
        this.mContext = context;
        this.mGiftBean = mGiftBean;
        View view = inflate(context, R.layout.gift_ranking, this);
        ButterKnife.bind(this, view);
        setOnClickListener(this);
        displayViews();
    }

    public void setOnClickListener(GiftRankingView.OnClickListener onClickListener) {
        this.onClickListener = onClickListener;
    }

    private void displayViews() {
        if (mGiftBean == null) {
            return;
        }
        giftRankingIv.setImageResource(mGiftBean.getResId());
        return;
    }

    public void setData(GiftBean giftBean) {
        this.mGiftBean = giftBean;
        displayViews();
    }


    public GiftBean getData() {
        return mGiftBean;
    }

    @Override
    public void onClick(View v) {
        if (onClickListener != null) {
            onClickListener.onClick(mGiftBean);
        }
    }

    public interface OnClickListener {
        void onClick(GiftBean entity);
    }
}
